import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';

@Component({
  selector: 'date-component',
  template: `
    <div>{{ day }}.{{ month }}.{{ year }} {{ hour }}:{{ minute }}</div>
  `,
  styles: []
})
export class DateComponent implements OnInit, OnChanges {
  // @ts-ignore
  @Input() date: string;

  // @ts-ignore
  day;
  // @ts-ignore
  month;
  // @ts-ignore
  year;
  // @ts-ignore
  hour;
  // @ts-ignore
  minute;

  constructor() {
    console.debug('ctrl');
  }

  ngOnChanges(changes: SimpleChanges): void {
    // if(changes.date) { ... }

    console.debug('change', changes);

    let date = new Date(this.date);

    this.day = date.getDate();
    this.month = date.getMonth() + 1;
    this.year = date.getFullYear();

    this.hour = date.getHours();
    this.minute = date.getMinutes();

        throw new Error('Method not implemented.');
    }

  ngOnInit(): void {
  }

}
